package com.cskaoyan.shopping.api;

import com.cskaoyan.mall.commons.result.ServiceCallResponse;
import com.cskaoyan.mall.dto.AllItemServiceResponse;
import com.cskaoyan.mall.dto.ItemDto;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SearchApiImpl {

    @Autowired
    IProductService iProductService;

    @GetMapping("/rpc/items")
    AllItemServiceResponse getAllProductItem() {

        List<ItemDto> allItems = iProductService.getAllItems();
        ServiceCallResponse<List<ItemDto>> callResponse = new ServiceCallResponse<>();
        callResponse.setCallData(allItems);
        return (AllItemServiceResponse) callResponse;
    }
}
